/**
 * 
 */
package design_pattern.command.awt.undo;

import java.awt.Panel;
import java.awt.event.ActionEvent;

/**
 * @author linzq
 * 
 */
public class ResetCommand extends Command {

  public ResetCommand(String caption, Panel p) {
    super(caption, p);
  }

  @Override
  public void execute(ActionEvent e) {
    if (!commands.isEmpty()) {
      if (index == 0) {
        commands.pop();
        index++;
      }
      Command command = commands.pop();
      command.execute(e);
    }
  }
}
